//
//  main.c
//  +17
//
//  Created by apple on 2016/12/12.
//  Copyright © 2016年 apple. All rights reserved.
//running.c--A useful program for runners

#include <stdio.h>
const int S_PER_M=60;
const int S_PER_H=3600;
const double M_PER_K=0.62137;
int main(void){
    double distk,distm;//跑过的距离（公里和英里）
    double rate;//英里每小时
    int min,sec;
    int time;
    double mtime;//跑一英里所需要的时间
    int mmin,msec;//跑一英里所需要的时间，以分和秒为单位
    printf("This program converts your time for a metric race\n");
    printf("to  a time for running a mile and to your average\n");
    printf("speed in miles per hour.\n");
    printf("Please enter,in kilometers,the distance run.\n");
    scanf("%lf",&distk);
    printf("Next enter the time in minutes and seconds.\n");
    printf("Begin by entering the minutes.\n");
    scanf("%d",&min);
    printf("Now enter the seconds.\n");
    scanf("%d",&sec);
    time=S_PER_M*min+sec;
    distm=M_PER_K*distk;
    rate=distm/time*S_PER_H;//英里／秒*秒／小时=英里／小时
    mtime=(double)time/distm;
    mmin=(int)mtime/S_PER_M;
    msec=(int)mtime%S_PER_M;
    printf("You ran %1.2f km (%1.2f miles) in %d min,%d sec.\n",distk,distm,min,sec);
    printf("%d sec.\nYour average speed was %1.2f mph.\n",msec,rate);
    return 0;
    
}
